import request from '@/axios'
import {
  SysRoleMenuDetailVo,
  SysRoleMenuEditQo,
  SysRoleMenuListVo,
  SysRoleMenuSearchQo
} from './types'
import { BaseDeleteQo } from '@/base/api/BaseQo'
import { KeyLabelValueVo } from '@/base/api/KeyLabelValueVo'

export const sysRoleMenuPageApi = (
  data: SysRoleMenuSearchQo
): Promise<IResponse<Array<SysRoleMenuListVo>>> => {
  return request.post({ url: '/sysRoleMenu/page.adw', data })
}

export const sysRoleMenuDetailApi = (id: number): Promise<IResponse<SysRoleMenuDetailVo>> => {
  const data = { id }
  return request.post({
    url: '/sysRoleMenu/detail.adw',
    data
  })
}

export const sysRoleMenuAddApi = (data: SysRoleMenuEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysRoleMenu/add.adw', data })
}

export const sysRoleMenuUpdateApi = (data: SysRoleMenuEditQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysRoleMenu/update.adw', data })
}

export const sysRoleMenuDeleteApi = (data: BaseDeleteQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysRoleMenu/delete.adw', data })
}

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]
export const selectSysRoleMenuRoleIdListApi = (
  data: SysRoleMenuSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysRoleMenu/selectRoleIdList.adw', data })
}
export const selectSysRoleMenuMenuIdListApi = (
  data: SysRoleMenuSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysRoleMenu/selectMenuIdList.adw', data })
}
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
